import React, { useEffect, useState } from "react";
import { useNavigate } from "react-router-dom";

function useAunt() {
  let nav = useNavigate();
  let token = localStorage.getItem("token");
  let [isLogin, setisLogin] = useState(false);
  useEffect(() => {
    if (token) {
      setisLogin(true);
    } else {
    //   alert("未登录");
      nav("/login");
      setisLogin(false);
    }
  });
  return {isLogin:isLogin}
}

export default useAunt;
